package com.cyh.anno;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component("myAspect")
@Aspect //标注当前是切面类
public class MyAspect {
    @Before("execution(void com.cyh.anno.Target.*(..))")
    public void before() {
        System.out.println("前置增强.....");
    }

    @AfterReturning("MyAspect.pointcut()")
    public void afterReturning() {
        System.out.println("后置增强.....");
    }

    @Around("pointcut()")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("环绕前增强");
        Object processs = pjp.proceed();
        System.out.println("环绕后增强");
        return pjp;
    }

    //切点表达式的抽取
    @Pointcut("execution(void com.cyh.anno.Target.*(..))")
    public void pointcut(){}
}
